<?php
defined('BASEPATH') OR exit('No direct script access allowed');

use \LeanCloud\Client;
use \LeanCloud\Storage\CookieStorage;

class BaseController extends CI_Controller
{
    //初始化：在正式使用数据存储之前，你需要使用自己的应用 key 进行初始化中间件
    function __construct()
    {
        parent::__construct();
        // 参数依次为 AppId, AppKey, MasterKey
        Client::initialize("MvoaV1bLqyNnsjv8HauT190P-gzGzoHsz", "pazbGtLYUD2deyy3wevi0vTk", "bSYzsxEqtnQSUGvaPKClDv7b");
        Client::useMasterKey(true);
        //云引擎提供了一个 LeanCloud\Storage\CookieStorage 模块，用 Cookie 来维护用户（User）的登录状态，要使用它可以在 app.php 中添加下列代码
        Client::setStorage(new CookieStorage());
    }

    function echo_json($message, $success = true)
    {
        $data = array(
            'message' => $message, 'success' => $success
        );
        header('Content-type: application/json;charset=UTF-8');
        echo json_encode($data);
    }


}